package com.pagepub.expo.manager;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.pagepub.expo.dao.AppDictDao;
import com.pagepub.expo.dao.AppFunctionDao;
import com.pagepub.expo.entity.AppDict;
import com.pagepub.expo.entity.AppFunction;

@Service
@Transactional
@RemotingDestination(channels = { "my-amf", "my-secure-amf" })
public class AppFunctionMng{
	@Autowired
	private AppFunctionDao appFunctionDao;


	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<AppFunction> findAll() {
		return appFunctionDao.findAll();
	}
	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<AppFunction> findAllByParentId(Long parentId) { //获取等级功能列表
		return appFunctionDao.findByParentId(parentId);
	}

	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public int getCount(Map<String, String> param){
		return appFunctionDao.getCount(param);
	}
	
	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<AppFunction> findByPage(int currentPage,int pageSize,Map<String, String> param){
		return appFunctionDao.findByPage(currentPage, pageSize, param);
	}


	@RemotingInclude
	public AppFunction add(AppFunction appDict) {
		appFunctionDao.insert(appDict);
		return appFunctionDao.findById(appDict.getFunctionId());
	}

	@RemotingInclude
	public Long remove(Long id) {
		appFunctionDao.delete(id);
		return id;
	}

	@RemotingInclude
	public AppFunction update(AppFunction appFunction) {
		appFunctionDao.update(appFunction);
		return appFunctionDao.findById(appFunction.getFunctionId());
	}
}
